﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AdministrationWindowsForms
{
    public partial class FrmPalavraPastoral : Form
    {
        public FrmPalavraPastoral()
        {
            InitializeComponent();
        }

        private void FrmPalavraPastoral_Load(object sender, EventArgs e)
        {
            try
            {
                using (ministerioprosperid1Entities banco = new ministerioprosperid1Entities())
                {
                    List<DEMembro> membros = banco.DEMembroes.OrderBy(q => q.Nome).ToList();
                    cboAutor.DataSource = membros;

                    cboAutor.SelectedValue = 118;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                DEPalavraPastoral palavra = new DEPalavraPastoral();

                palavra.Titulo = this.txtTitulo.Text;
                palavra.Versiculo = this.txtVersiculo.Text;
                palavra.Texto = this.txtPalavra.Text + "<br /><strong>" + this.txtSaudacao.Text + "</strong>";
                palavra.Data = DateTime.Today;
                palavra.CodigoAutor = Convert.ToInt32(cboAutor.SelectedValue);

                using (ministerioprosperid1Entities banco = new ministerioprosperid1Entities())
                {
                    banco.AddToDEPalavraPastorals(palavra);
                    banco.SaveChanges();
                }

                MessageBox.Show("Palavra cadastrada com sucesso.");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnParagrafo_Click(object sender, EventArgs e)
        {
            this.txtPalavra.SelectedText = "<p class=\"text\">" + this.txtPalavra.SelectedText + "</p>";
        }

        private void btnCitacao_Click(object sender, EventArgs e)
        {
            this.txtPalavra.SelectedText = "<span class=\"citacaoBiblica\">" + this.txtPalavra.SelectedText + "</span>";
        }

        private void btnFim_Click(object sender, EventArgs e)
        {
            this.txtPalavra.SelectedText = "<br /><center>" + this.txtPalavra.SelectedText + "</center>";
        }
    }
}
